﻿@using CNav.Model
@using CNav.Support
@model UserProfileModel

@{
    ViewBag.Title = "User Profile";
    var user = (SessionUser)Session[Constant.SessionUser];
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <div id="userProfileAccordion">
        <ol>
            @if (!Model.IsBusinessAdmin)
            {
                <li>
                    @Html.LabelFor(m => m.Title)
                    @Html.DisplayFor(model => model.Title)
                </li>
                
                <li>
                    @Html.LabelFor(m => m.FirstName)
                    @Html.DisplayFor(model => model.FirstName)
                </li>

                <li>
                    @Html.LabelFor(m => m.Lastname)
                    @Html.DisplayFor(model => model.Lastname)
                </li>
            }
            else
            {
                <li>
                    @Html.LabelFor(m => m.FirstName, "Business name")
                    @Html.DisplayFor(model => model.FirstName)
                </li>
            }

            <li>
                @Html.LabelFor(m => m.Email)
                @Model.Email
            </li>
            <li>
                @Html.LabelFor(m => m.UserPosition)
                @Html.DisplayFor(model => model.UserPosition)
            </li>
            <li>
                @Html.LabelFor(m => m.PhoneNumber)
                @Html.DisplayFor(model => model.PhoneNumber)
            </li>

            <li>
                @Html.LabelFor(m => m.FaxNumber)
                @Html.DisplayFor(model => model.FaxNumber)
            </li>

            <li>
                @Html.LabelFor(m => m.IsLogOnText, "Is logged in")
                @Html.DisplayFor(model => model.IsLogOnText)
            </li>

            <li>
                @Html.LabelFor(m => m.LogOffDate, "Log off date")
                @Model.LogOffDate.ToString(UIConstant.DateFormat)
            </li>

            <li>
                @Html.LabelFor(m => m.LogOnAttempt, "Log in attempts")
                @Html.DisplayFor(model => model.LogOnAttempt)
            </li>

            <li>
                @Html.LabelFor(m => m.LockOutExpireDate, "Lock expire date")
                @Model.LockOutExpireDate.ToString(UIConstant.DateFormat)
            </li>

            <li>
                @Html.LabelFor(m => m.PassExpireDate, "Password expire date")
                @Model.PassExpireDate.ToString(UIConstant.DateFormat)
            </li>
            <li>
                @Html.LabelFor(m => m.MachineIP, "Machine IP")
                @Html.DisplayFor(model => model.MachineIP)
            </li>

            <li>
                @Html.LabelFor(m => m.AccountExpireDate)
                @Model.AccountExpireDate.ToShortDateString()
            </li>

            <li>
                <label>&nbsp;</label>
                @Html.HiddenFor(m => m.ID)
                @if (user.IsBusinessAdmin)
                {
                    if (user.ID == Model.ID)
                    {
                    <input type="button" value="Edit" id="editBusinessButton" />
                    }
                    else
                    {
                    <input type="button" value="Edit" id="editButton" />
                    }
                }
            </li>

        </ol>
    </div>
}
<script>

    $(document).ready(function () {
        var cc = new CaseCentre();
        var isBusiness = false;
        @if (user.IsBusinessAdmin && user.ID == Model.ID)
        {
            @Html.Raw("            isBusiness = true;")
        }

        if (isBusiness == true) {
            cc.BindEdit('#editBusinessButton', '#ID', '@Url.Content("~/RegisterBusiness/Edit/")');
        } else {
            cc.BindEdit('#editButton', '#ID', '@Url.Content("~/UserProfile/Edit/")');
        }
    });
</script>
